#include "newgame.h"

void newgame(SDL_Surface *screeno)
{

SDL_Event event;
SDL_Surface *bgo = SDL_LoadBMP("img/gametype/rien.bmp");
SDL_Surface *imageo = SDL_DisplayFormat(bgo);
SDL_Rect desto,srco;

int i=0;


int done = 1;
while(done)
{
desto.x = 0;//Display the image at the (X,Y) coordinates (100,100)
desto.y = 0;
srco.x = 0;//
srco.y = 0;

srco.w = imageo->w; //Use image->w to display the entire width of the image
srco.h = imageo->h; //Use image->h to display the entire height of the image

desto.w = imageo->w;
desto.h = imageo->h;

SDL_BlitSurface(imageo, &srco, screeno, &desto);

//Flip the backbuffer to the primary Hardware Video Memory
SDL_Flip(screeno);

while (SDL_PollEvent(&event))
{
// check for messages
switch (event.type)
{
// exit if the window is closed
case SDL_QUIT:
done = 0;
break;
// check for keypresses


case SDL_KEYDOWN:
{// exit if ESCAPE is pressed
if (event.key.keysym.sym == SDLK_ESCAPE)
{done = 0;}
else
    if ((event.key.keysym.sym == SDLK_DOWN)||(event.key.keysym.sym == SDLK_RIGHT))
{//Construct the destination rectangle for our blit
if(i==0)
{ bgo = SDL_LoadBMP("img/gametype/A.bmp"); imageo = SDL_DisplayFormat(bgo);i++;
}
else if(i==1)
{ bgo = SDL_LoadBMP("img/gametype/B.bmp"); imageo = SDL_DisplayFormat(bgo);i++;
}
else if(i==2)
{ bgo = SDL_LoadBMP("img/gametype/C.bmp"); imageo = SDL_DisplayFormat(bgo);i++;
}
else if(i==3)
{ bgo = SDL_LoadBMP("img/gametype/D.bmp"); imageo = SDL_DisplayFormat(bgo);i++;
}
else if(i==4)
{ bgo = SDL_LoadBMP("img/gametype/A.bmp"); imageo = SDL_DisplayFormat(bgo);i=1;

}

SDL_BlitSurface(imageo, &srco, screeno, &desto);


    ;}
else if ((event.key.keysym.sym == SDLK_UP)||(event.key.keysym.sym == SDLK_LEFT))
{//Construct the destination rectangle for our blit
if(i==0)
{ bgo = SDL_LoadBMP("img/gametype/C.bmp"); imageo = SDL_DisplayFormat(bgo);i=4;

}
if(i==4)
{ bgo = SDL_LoadBMP("img/gametype/C.bmp"); imageo = SDL_DisplayFormat(bgo);i--;

}
else if(i==3)
{ bgo = SDL_LoadBMP("img/gametype/B.bmp"); imageo = SDL_DisplayFormat(bgo);i--;

}
else if(i==2)
{ bgo = SDL_LoadBMP("img/gametype/A.bmp"); imageo = SDL_DisplayFormat(bgo);i--;
}
else if(i==1)
{ bgo = SDL_LoadBMP("img/gametype/D.bmp"); imageo = SDL_DisplayFormat(bgo);i=4;
}
SDL_BlitSurface(imageo, &srco, screeno, &desto);


    ;}

else

    if ((event.key.keysym.sym == SDLK_RETURN)||(event.key.keysym.sym == SDLK_KP_ENTER))
    {
    if (i==0)
    {
        bgo = SDL_LoadBMP("img/gametype/A.bmp"); imageo = SDL_DisplayFormat(bgo);i++;
    }

    else if(i==1)
     {
     // newsand();
     }
    else if(i==2)
    {
     newwood(screeno);

    }
    else if(i==3)
    {
     newpaper(screeno);

    }
    else if(i==4)
    {
     // newspace();

    }

}



}}}









}
}


